<?php
class Application_Form_Product extends Zend_Form
{
    public function __construct($options = null)
    {
        parent::__construct($options);
        $this->setName('product');
		$this->setAttrib('enctype', 'multipart/form-data');
       //id = new Zend_Form_Element_Hidden('id');
       // $id->addFilter('Int');


        $categories = new Zend_Form_Element_Select('category_id');
        $categories->setLabel('Category:')
            ->setRequired(true);
        $categories_db = new Project_Category_Table();
        foreach($categories_db->getCategories() as $category)
        {
        	$categories->addMultiOption($category->category_id, $category->title);
        }
        $model = new Zend_Form_Element_Text('model');
        $model->setLabel('Model:')
        	->setRequired(true)
        	->addFilter('StripTags')
            ->addFilter('StringTrim')
            ->addValidator('NotEmpty');
        $date = new Zend_Form_Element_Text('date');
        $date->setLabel('Date:')
        	->setRequired(true)
            ->addValidator('NotEmpty');
        $image = new Zend_Form_Element_File('image');
        $image->setLabel('Image:')
			->addValidator('Size', false, 1024000)//1 mb
			->addValidator('Extension',false, 'jpg,png,gif');
        $description = new Zend_Form_Element_Textarea('description');
        $description->setLabel('Description:')
        	->setRequired(true)
        	->addFilter('StripTags')
            ->addFilter('StringTrim')
            ->addValidator('NotEmpty');

        $price = new Zend_Form_Element_Text('price');
        $price->setLabel('Price:')
            ->setRequired(true)
            ->addFilter('StripTags')
            ->addFilter('Alnum')
            ->addValidator('NotEmpty');

        $quantity = new Zend_Form_Element_Text('quantity');
		$quantity->setLabel('Quantity:')
			->setRequired(true)
            ->addFilter('StripTags')
            ->addFilter('Alnum')
            ->addValidator('NotEmpty');

        $submit = new Zend_Form_Element_Submit('submit');
        $submit->setAttrib('id', 'submitbutton');
        $submit->setIgnore(true);

        $this->addElements(array($categories, $model, $date, $description, $price, $quantity, $image, $submit));
    }
}
